package com.example.train.api.controller.v1;

import com.example.train.app.service.EmployeeService;
import com.example.train.domain.entity.Employee;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: chundong.huang@hand-china.com
 * @Date: 2023/3/25 15:39
 */
@RestController
@RequestMapping("/emp")
public class EmployeeController {

    private final EmployeeService employeeService;

    public EmployeeController(EmployeeService employeeService){
        this.employeeService = employeeService;
    }

    @GetMapping("/list")
    public ResponseEntity<?> list(@RequestParam("id") Long id){
        return ResponseEntity.ok(employeeService.list(id));
    }

    @PostMapping("/del")
    public ResponseEntity<?> del(@RequestParam("id") Long id){
        return ResponseEntity.ok(employeeService.del(id));
    }

    @PostMapping("/insert")
    public ResponseEntity<?> insert(@RequestBody Employee employee){
        return ResponseEntity.ok(employeeService.insert(employee));
    }

    @PostMapping("/update")
    public ResponseEntity<?> update(@RequestBody Employee employee){
        return ResponseEntity.ok(employeeService.update(employee));
    }
}
